function randomString(length: number, chars?: string) {
  let result = '', defaultChars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
  if (chars) defaultChars = chars
  for (let i = length; i > 0; --i) {
    let index = Math.floor(Math.random() * defaultChars.length)
    result += defaultChars[index]
  }
  return result
}

export { randomString }
